<!-- ************************************************************************************************************ -->
<!-- fileName          : admin_homepagemiddlelink.jsp 															  -->
<!-- summary           : admin端  “网站相关联考链接” 相关编辑 														  		  -->
<!-- ************************************************************************************************************ -->

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>admin_homepagemiddlelink</title>
<script type="text/javascript" src="../../js/jquery.js"></script>
<script type="text/javascript" src="../../js/validator.js"></script>
<script type="text/javascript">
$.ajaxSetup ({
   	cache: false //关闭AJAX相应的缓存
});
</script>
<style type="text/css">
body{
background-image:url(../../image/admin_bg.png);
background-repeat:repeat-x;
margin-left: 0px;
margin-top: 0px;
margin-right: 1px;
margin-bottom: 0px;
font-family:Microsoft YaHei;
font-size:13px;
}

h2{
font-family:Microsoft YaHei;
color:#fff;
margin: 5px 5px 5px 5px;
font-size:16px;
}

</style>
</head>
<body>

<%
	//设置请求的字符编码以支持中文
	request.setCharacterEncoding ("utf-8");

	//获取请求参数

	//从web.xml获取全局参数
	String drv=config.getServletContext().getInitParameter("DBDriver");
	String url=config.getServletContext().getInitParameter("DBURL");
	String uid=config.getServletContext().getInitParameter("DBUser");
	String pwd=config.getServletContext().getInitParameter("DBPass");
	
	//构建SQL字符串和JDBC对象
	String strSQL = "SELECT * FROM immie0_immi.homepagemiddlelink h WHERE 1=1";	//  homepagemiddlelink表有三个字段(id、name、address) 
	Connection conn = null;
	PreparedStatement pstmt = null;	
	ResultSet rs = null;
	
	try {
		Class.forName(drv).newInstance();
		conn = DriverManager.getConnection(url,uid,pwd);
		pstmt = conn.prepareStatement(strSQL);		
		
		rs = pstmt.executeQuery();
%>

<h2>编辑网站相关链接</h2>
	<div style="margin:60px auto; width:650px;">
		<form id="hpmlForm" method="post" action="AddHpml.do">
		<table>
			<tr>
            	<th style="text-align:center; width:150px;">链接名称</th>  
            	<th style="text-align:center; width:400px;">链接地址</th>  
            	<th style="text-align:center; width:100px;">操作</th> 
			</tr>
			<% while(rs.next()) { %>	
				<tr>
					<td style="text-align:center; width:150px;"><%=rs.getString(2) %></td>
					<td style="text-align:center; width:400px;"><%=rs.getString(3) %></td>
					<td style="text-align:center; width:100px;"><a href="DeleteHpml.do?id=<%=rs.getString(1) %>" onClick="delcfm()">删除</a>
					</td>
				</tr>
			<%	}		%>
			<tr>
				<td style="text-align:center; width:150px;"><input type="text" name="hpml_name" id="hpml_name" style="text-align:center; width:150px;" onblur="checkHpml_name();" onClick="if(this.value=='请输入...')this.value=''" /></td>
				<td style="text-align:center; width:400px;"><input type="text" name="hpml_address" id="hpml_address" style="text-align:center; width:400px;" onblur="checkHpml_address();" onClick="if(this.value=='请输入...'|this.value=='请输入正确格式的网址，如“http://www.baidu.com”')this.value=''" /></td>
				<td style="text-align:center; width:100px;"><input type="button" value="添加链接" onclick="add_hpml(this.form);"/></td>
			</tr>	
		</table>
		</form>
	</div>

<%		
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
	} catch (InstantiationException e) {
	    e.printStackTrace();
	} catch (IllegalAccessException e) {
		e.printStackTrace();
	} catch (SQLException e) {
		e.printStackTrace();
	} 
	finally {
		if (rs != null) {
			rs.close();
			rs = null;
		}
		if (pstmt != null) {
			pstmt.close();
			pstmt = null;
		}		
		if (conn != null) {
			conn.close();
			conn = null;
		}
	}
%>

</body>
</html>